package com.shop2cn.iapi.agentproducts.service;

import com.google.common.reflect.TypeToken;
import com.shop2cn.iapi.agentproducts.parameter.CatalogPriceDto;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.EnvSetup;

import java.util.List;

/**
*查询规格售价和代理价Call
*FreeMaker Template自动生成代码
*/
public class GetPriceByCatalogIdListCall extends YmatouBaseCall{
	private static String opurl ="product/getPriceByCatalogIdList";
	
	public GetPriceByCatalogIdListCall() {
		super(EnvSetup.getSystemUrl("agentproducts_iapi"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	public List<CatalogPriceDto> getCatalogPriceList(){
		String sResults=getJsonObject().get("data").getAsJsonObject().get("catalogPriceList").getAsJsonArray().toString();
		List<CatalogPriceDto> FreezeProductResultList=(List<CatalogPriceDto>) FormatUtil.GSONToObject(sResults, new TypeToken<List<CatalogPriceDto>>(){}.getType());
		return FreezeProductResultList;
	}
}